package server;

/**
 * @author xing fang bin
 * @date 2021/8/11 0011 21:14
 * @description 封装请求头
 */
public class HttpProtocolUtil {

    /**
     * 封装请求成功header
     * @param length
     * @return
     */
    public static String getHttpHeader200(long length) {
        return "HTTP/1.1 200 OK \n" +
                "Content-Type: text/html;charset=utf-8 \n" +
                "Content-Length: " + length + "\n" +
                "\r\n";
    }

    /**
     * 封装请求失败header
     * @return
     */
    public static String getHttpHeader404() {
        String str404 = "<h1>404 not found</h1>";
        return "HTTP/1.1 404 NOT Found \n" +
                "Content-Type: text/html;charset=utf-8 \n" +
                "Content-Length: " + str404.getBytes().length + "\n" +
                "\r\n" + str404;
    }

}
